<?php
$this->breadcrumbs=array(
	'Locked Event Management',
);
?>
<div class="row-fluid">
	<div class="span12">
		<div class="row-fluid">
			<h4>Event and Booked Unlocked Management</h4>
		</div>
		<hr >
		<div class="row-fluid">
			<div class="tabbable">
				<ul id="myTab" class="nav nav-tabs">
					<li class="active">
						<a href="#tab_event" data-toggle="tab" onclick="showevent()">
							<b class="blue">
								Event
							</b>
						</a>
					</li>
					<li>
						<a href="#tab_book" data-toggle="tab" onclick="showbooked()">
							<b class="blue">
								Booked Management
							</b>
						</a>
					</li>
				</ul>
				<div class="tab-content">
					<div class="tab-pane active"  id="tab_event">
						<div class="table-header">
					       Event Locked
					    </div>
					    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
					        <thead>
					                <tr>
					                    <th width="20"></th>
					                    <th>Event Code</th>
					                    <th>Main Title</th>
					                    <th>Category</th>
					                    <th>Status</th>
					                    <th>User</th>
					                    <th>User Email</th>
					                    <!-- <th>Ticket Code</th>
					                    <th width="50">Payment Type</th>
					                    <th>Status</th>
					                    <th>Payment</th>
					                    <th>Book date</th>
					                    <th width="20"></th> -->
					                </tr>
					        </thead>

					        <tbody>
					             <?php
					                    if (isset($event_locked)):
					                        foreach ($event_locked as $k=> $event) :
					              ?>
					                <tr>
					                    <td class="center">
					                        <label>
					                            <?php echo $k+1; ?>
					                        </label>
					                    </td>
					                    <td>
					                    	<b class="blue">
					                        	<?php echo $event->event_code ?>
					                        </b>
					                    </td>
					                    <td>
					                    	<b class="green">
					                        	<?php echo $event->translate[1]['main_title']; ?>
					                        </b>
					                    </td>
					                    <td>
					                    	<b>
					                        	<?php echo $event->category['name']; ?>
					                        </b>
					                    </td>
					                    <td>
					                    	<a href="#" onclick="unlock(<?php echo $event->id; ?>)" title="Click here to unlock event">
					                    		<span class="label label-important">
						                        	Locked
						                        </span>
					                    	</a>             	
					                    </td>
					                    <td>
					                    	<b class="green">
					                        	<?php $user = MyFunctionCustom::get_user_info($event->user_lock); ?>
					                        	<?php echo $user->first_name . ' ' . $user->last_name; ?>
					                        </b>
					                    </td>
					                    <td>
					                    	<b>
					                        	<?php echo $user->email; ?>
					                        </b>
					                    </td>
					                </tr>
					            <?php endforeach;endif; ?>
					        </tbody>
					    </table>
					</div>
					<div class="tab-pane"  id="tab_book">

					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	function showbooked()
	{
		$.ajax({
			url: '<?php echo Yii::app()->createAbsoluteUrl("bookingsystem/eventlocked/viewbooked"); ?>',
			async: true,
			beforeSend: function(){
                $('#tab_book').empty();
                $('#tab_event').empty();
                $('#tab_book').append('<div class="loading"><div style="width:134px;height:100px;margin:0 auto;padding-top: 10px;"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/frontend/images/ajaxloader.gif"></div></div>');
            },
			success: function(data){
				$('#tab_book').html(data);
			}
		});
	}
	function showevent()
	{
		$.ajax({
			url: '<?php echo Yii::app()->createAbsoluteUrl("bookingsystem/eventlocked/viewevent"); ?>',
			async: true,
			beforeSend: function(){
                $('#tab_event').empty();
                $('#tab_event').append('<div class="loading"><div style="width:134px;height:100px;margin:0 auto;padding-top: 10px;"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/frontend/images/ajaxloader.gif"></div></div>');
            },
			success: function(data){
				$('#tab_event').html(data);
			}
		});
	}
	function unlock(id){
		$.ajax({
			url: '<?php echo Yii::app()->createAbsoluteUrl("bookingsystem/eventlocked/unlockevent") ?>',
			data: {event_id : id},
			type:'POST',
			beforeSend: function(){
				$('#tab_event').empty();
				$('#tab_event').append('<div class="loading"><div style="width:134px;height:100px;margin:0 auto;padding-top: 10px;"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/frontend/images/ajaxloader.gif"></div></div>');
			},
			success: function(data){
				window.location.reload();
			}
		});
	}
</script>